﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace MLSharp.See5.Tests
{
	/// <summary>
	/// This is a simple helper class that encapsulates some common
	/// properties that are used by all the See5 test fixtures,
	/// such as the path to See5.
	/// </summary>
	internal static class TestingOptions
	{
		#region Private Static Fields

		/// <summary>
		/// The path to the See5Sam executable.
		/// </summary>
		private const string mSee5SamPath = @"..\..\..\..\ExternalReferences\See5Sam.exe";

		/// <summary>
		/// The working directory for See5 to use.
		/// </summary>
		private const string mWorkingDirectory = @".\See5";

		/// <summary>
		/// The path to See5X.exe.
		/// </summary>
		private readonly static string mSee5XPath;

		#endregion

		#region Public Static Properties

		/// <summary>
		/// The path to See5X.exe.
		/// </summary>
		public static string See5XPath
		{
			get
			{
				return mSee5XPath;
			}
		}

		/// <summary>
		/// The path to See5Sam.exe.
		/// </summary>
		public static string See5SamPath
		{
			get
			{
				return mSee5SamPath;
			}
		}

		/// <summary>
		/// The working directory to use.
		/// </summary>
		public static string WorkingDirectory
		{
			get
			{
				return mWorkingDirectory;
			}
		}

		#endregion

		#region Static Constructor

		/// <summary>
		/// Finds See5 executables and stores
		/// the paths in static members.
		/// </summary>
		static TestingOptions()
		{
			string[] candidatePaths = new string[]
			                          	{
											@"C:\Program Files\See5\see5x.exe",
											@"C:\Program Files (x86)\See5\see5x.exe"
			                          	};

			for (int i = 0; i < candidatePaths.Length; i++)
			{
				if (File.Exists(candidatePaths[i]))
				{
					mSee5XPath = candidatePaths[i];
					break;
				}
			}

			if (mSee5XPath == null)
			{
				throw new FileNotFoundException("See5x.exe was not found in any of the expected locations.");
			}
		}

		#endregion
	}
}
